package com.feiyue.hikari.service;

import com.feiyue.hikari.mapper.UserMapper;
import com.feiyue.hikari.modle.User;
import com.feiyue.hikari.modle.UserExample;
import com.feiyue.hikari.utils.ResponInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Author: 86185
 * Date: 2019/9/13
 * Time: 11:02
 * Description: No Description
 */
@Service
@Slf4j
public class UserService {

    @Resource
    private UserMapper userMapper;

    public ResponInfo<User> getById(String  account) {
        UserExample example = new UserExample();
        example.createCriteria().andAccountEqualTo(account);
        List<User> users = userMapper.selectByExample(example);

        User user = new User();
        if (!users.isEmpty()){
            user = users.get(0);
        }
        ResponInfo<User> result = ResponInfo.makeSuc(user);
        return result;

    }
}
